﻿Public Class JSON
    Public Shared Function Serialize(ByVal Input As Object, ByVal Type As System.Type) As String
        Dim jsonResponse As New System.Runtime.Serialization.Json.DataContractJsonSerializer(Type)
        Dim res As String

        Dim stm As New System.IO.MemoryStream
        Using (stm)
            jsonResponse.WriteObject(stm, Input)
            res = System.Text.Encoding.UTF8.GetString(stm.ToArray())
        End Using

        Return res
    End Function

End Class
